package com.letian.web.controller.im;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.letian.common.annotation.Log;
import com.letian.common.core.controller.BaseController;
import com.letian.common.core.domain.AjaxResult;
import com.letian.common.enums.BusinessType;
import com.letian.im.domain.ImMyFriends;
import com.letian.im.service.IImMyFriendsService;
import com.letian.common.utils.poi.ExcelUtil;
import com.letian.common.core.page.TableDataInfo;

/**
 * 朋友列表Controller
 * 
 * @author bmz
 * @date 2023-08-13
 */
@RestController
@RequestMapping("/info/myFriends")
public class ImMyFriendsController extends BaseController
{
    @Autowired
    private IImMyFriendsService imMyFriendsService;

    /**
     * 查询朋友列表列表
     */
    @PreAuthorize("@ss.hasPermi('info:myFriends:list')")
    @GetMapping("/list")
    public TableDataInfo list(ImMyFriends imMyFriends)
    {
        startPage();
        List<ImMyFriends> list = imMyFriendsService.selectImMyFriendsList(imMyFriends);
        return getDataTable(list);
    }

    /**
     * 导出朋友列表列表
     */
    @PreAuthorize("@ss.hasPermi('info:myFriends:export')")
    @Log(title = "朋友列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ImMyFriends imMyFriends)
    {
        List<ImMyFriends> list = imMyFriendsService.selectImMyFriendsList(imMyFriends);
        ExcelUtil<ImMyFriends> util = new ExcelUtil<ImMyFriends>(ImMyFriends.class);
        util.exportExcel(response, list, "朋友列表数据");
    }

    /**
     * 获取朋友列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:myFriends:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(imMyFriendsService.selectImMyFriendsById(id));
    }

    /**
     * 新增朋友列表
     */
    @PreAuthorize("@ss.hasPermi('info:myFriends:add')")
    @Log(title = "朋友列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImMyFriends imMyFriends)
    {
        return toAjax(imMyFriendsService.insertImMyFriends(imMyFriends));
    }

    /**
     * 修改朋友列表
     */
    @PreAuthorize("@ss.hasPermi('info:myFriends:edit')")
    @Log(title = "朋友列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImMyFriends imMyFriends)
    {
        return toAjax(imMyFriendsService.updateImMyFriends(imMyFriends));
    }

    /**
     * 删除朋友列表
     */
    @PreAuthorize("@ss.hasPermi('info:myFriends:remove')")
    @Log(title = "朋友列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(imMyFriendsService.deleteImMyFriendsByIds(ids));
    }
}
